/*
 * @name: 线索列表
 * @Author: icepual
 * @Date: 2020-06-04
 */
<template>
    <div class="container sales-leads-wrap">
        <!-- header -->

        <div class="content-wrapper">
            <el-row
                class="search-wrapper"
                :gutter="20"
                v-if="!hideSearch"
            >
                <el-form
                    label-position="right"
                    label-width="84px"
                    ref="searchfrom"
                    size="small">


                    <el-form-item label="公司名称">
                        <el-input
                            v-model.trim="filterData.company_name"
                            placeholder="请输入公司名称"
                            type="text"
                            size="small"
                            style="width: 193px;"
                            @keyup.native.enter="getTableData(1)"
                        />
                    </el-form-item>

                    <el-form-item label="手机号码">
                        <el-input
                            v-model.trim="filterData.hire_username"
                            placeholder="请输入手机号码"
                            type="text"
                            size="small"
                            style="width: 193px;"
                            @keyup.native.enter="getTableData(1)"
                        />
                    </el-form-item>


                    <el-form-item label="申请状态">
                        <el-select
                            v-model="filterData.verify"
                            filterable
                            @change="getTableData(1)"
                            placeholder="请选择"
                        >
                            <el-option
                                v-for="(item, index) in verify_list"
                                :key="index"
                                :label="item.name"
                                :value="item.status"
                            />
                        </el-select>
                    </el-form-item>
                    <el-form-item label="是否已委派">
                        <el-select
                            v-model="filterData.sales_leads_assign"
                            filterable
                            @change="getTableData(1)"
                            placeholder="请选择"
                        >
                            <el-option
                                v-for="(item, index) in sales_leads_assign_list"
                                :key="index"
                                :label="item.name"
                                :value="item.status"
                            />
                        </el-select>
                    </el-form-item>
                    <el-form-item label="已委派销售">
                        <!-- <el-input
                            v-model.trim="filterData.sales_leads_admin_true_name"
                            placeholder=""
                            type="text"
                            size="small"
                            style="width: 193px;"
                            @keyup.native.enter="getTableData(1)"
                        /> -->
                        <el-autocomplete
                            class="inline-input"
                            v-model.trim="filterData.sales_leads_admin_true_name"
                            :fetch-suggestions="querySearch"
                            placeholder="姓名"
                            @select="getTableData(1)"
                            @keyup.native.enter="getTableData(1)"
                        />
                    </el-form-item>
                    <el-form-item label="合同状态">
                        <el-select
                            v-model="filterData.sales_leads_contract_verify"
                            filterable
                            @change="getTableData(1)"
                            placeholder="请选择"
                        >
                            <el-option
                                v-for="(item, index) in sales_leads_contract_verify_list"
                                :key="index"
                                :label="item.name"
                                :value="item.status"
                            />
                        </el-select>
                    </el-form-item>

                    <el-button
                        size="small"
                        style="margin-left: 18px;"
                        @click="fnResetForm('searchfrom')"
                    >重置筛选</el-button>
                    <el-button
                        size="small"
                        type="primary"
                        style="margin-left: 18px;"
                        @click="getTableData(1)"
                    >搜索</el-button>
                </el-form>
            </el-row>
            <div
                class="show-search-btn"
                v-if="showHideBtn"
                @click="hideSearch = !hideSearch">
                <i
                    class="iconfont el-icon-hand-xiangxia"
                    :class="{reverse: !hideSearch}" />
            </div>
            <!-- /header -->

            <!-- table -->
            <div class="table-wrapper">
                <el-table
                    :data="tableData"
                    height="100%"
                    style="width: 100%;"
                    border
                    ref="tableData"
                    @sort-change="handleSortChanged"
                    @select="fnSelect"
                    @select-all="fnSelectAllTop"
                    @selection-change="handleSelectionChange"
                >
                    <el-table-column
                        type="selection"
                        width="40"
                        :fixed="deviceType == 'mobile' ? false : 'left'"
                        :selectable="selectionFilter"
                    />
                    <el-table-column
                        type="index"
                        width="80"
                        label="序号"
                        align="center"
                        :fixed="deviceType == 'mobile' ? false : 'left'"
                    />
                    <el-table-column
                        prop="company_name"
                        label="公司名称"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                        :fixed="deviceType == 'mobile' ? false : 'left'"
                        min-width="120"
                    />
                    <el-table-column
                        prop="hire_username"
                        label="注册手机号"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                        :width="150"
                    />
                    <!-- <el-table-column
                        prop="type"
                        label="店铺类型"
                        show-overflow-tooltip
                        :formatter="shopTypeFormatter"
                        align="center"
                        width="120"
                    /> -->
                    <!-- <el-table-column
                        prop="shop_name"
                        label="店铺名称"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                        width="120"
                    /> -->
                    <el-table-column
                        prop="shop_url"
                        label="第三方平台链接"
                        width="120"
                        show-overflow-tooltip
                    >
                        <template slot-scope="scope">
                            <a
                                v-if="scope.row.shop_url !== ''"
                                target="_blank"
                                class="shop-url"
                                style="white-space: nowrap"
                                :href="scope.row.shop_url"
                            >
                                {{ scope.row.shop_url }}
                            </a>
                            <p v-else>
                                --
                            </p>
                        </template>
                    </el-table-column>
                    <!-- <el-table-column
                        prop="legal_name"
                        label="法人姓名"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                        min-width="120"
                    /> -->
                    <!-- <el-table-column
                        prop="contact_name"
                        label="业务联系人姓名"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                        min-width="120"
                    /> -->
                    <!-- <el-table-column
                        prop="contact_email"
                        label="联系邮箱"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                        min-width="120"
                    /> -->
                    <!-- <el-table-column
                        prop="address"
                        label="联系地址"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                        min-width="150"
                    /> -->
                    <el-table-column
                        prop="verify"
                        label="申请状态"
                        show-overflow-tooltip
                        :formatter="verifyFormatter"
                        align="center"
                    />
                    <el-table-column
                        prop="sales_leads.admin_no"
                        label="是否已委派"
                        show-overflow-tooltip
                        :formatter="assignFormatter"
                        align="center"
                        :width="130"
                    />
                    <el-table-column
                        prop="sales_leads.admin_true_name"
                        label="被委派销售"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                        :width="130"
                    />
                    <el-table-column
                        prop="sales_leads.vas_money_submit"
                        label="增值服务费用(元)"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                        :width="130"
                    />
                    <el-table-column
                        prop="sales_leads.vas_remark_submit"
                        label="增值服务备注"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                        :width="130"
                    />
                    <el-table-column
                        prop="remark"
                        label="备注"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                    />
                    <el-table-column
                        v-if="authResult.auth_admin"
                        prop="sales_leads.contract_verify"
                        label="合同状态"
                        show-overflow-tooltip
                        :formatter="statusFormatter"
                        align="center"
                    />
                    <!-- <el-table-column
                prop=""
                label="合同状态"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="center"
                fixed="right"
            /> -->
                    <el-table-column
                        v-if="authResult.auth_admin"
                        prop="sales_leads.contract_money_submit"
                        label="保证金金额(元)"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                        min-width="120"
                    />
                    <el-table-column
                        v-if="authResult.auth_admin"
                        prop="sales_leads.contract_valid_year_submit"
                        label="服务年限"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                    />
                    <el-table-column
                        prop="referrer"
                        label="推荐人"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                    />
                    <el-table-column
                        prop="referrer_channel"
                        label="来源"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                    />
                    <el-table-column
                        prop="referrer_platform"
                        label="客户端"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                    />
                    <el-table-column
                        prop="create_time"
                        label="提交时间"
                        show-overflow-tooltip
                        :formatter="emptyFormatter"
                        align="center"
                        :fixed="deviceType == 'mobile' ? false : 'right'"
                    >
                        <template slot-scope="scope">
                            {{ scope.row.create_time * 1000 | dateFormatter('yyyy/MM/dd HH:mm') }}
                        </template>
                    </el-table-column>
                    <el-table-column
                        label="操作"
                        align="center"
                        :fixed="deviceType == 'mobile' ? false : 'right'"
                        :width="250"
                    >
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                class="btn-operate"
                                @click="fnShowVerifyPass(scope.row)"
                                :disabled="!scope.row.sales_leads || !scope.row.sales_leads.admin_no || scope.row.verify !==1"
                            >
                                通过
                            </el-button>
                            <el-button
                                type="text"
                                class="btn-operate"
                                @click="fnShowVerifyUnpass(scope.row)"
                                :disabled="!scope.row.sales_leads || !scope.row.sales_leads.admin_no || scope.row.verify !==1"
                            >
                                不通过
                            </el-button>
                            <el-button
                                type="text"
                                class="btn-operate"
                                @click="fnRemark(scope.row)"
                            >
                                备注
                            </el-button>
                            <el-button
                                type="text"
                                class="btn-operate"
                                v-if="authResult.auth_admin"
                                :disabled="!scope.row.sales_leads || !scope.row.sales_leads.contract_url_submit"
                                @click="fnShowContract(scope.row.sales_leads.contract_url_submit)"
                            >
                                查看合同
                            </el-button>
                            <el-button
                                type="text"
                                class="btn-operate"
                                @click="fnAssign(scope.row)"
                                v-if="authResult.auth_admin && scope.row.sales_leads && !scope.row.sales_leads.admin_no"
                            >
                                委派
                            </el-button>
                            <el-button
                                type="text"
                                class="btn-operate"
                                @click="fnUnassign(scope.row)"
                                v-if="authResult.auth_admin && scope.row.sales_leads && scope.row.sales_leads.admin_no"
                            >
                                移除委派
                            </el-button>
                            <el-button
                                type="text"
                                class="btn-operate"
                                v-if="authResult.auth_admin"
                                @click="fnPassContract(scope.row)"
                                :disabled="scope.row.sales_leads && scope.row.sales_leads.contract_verify !== 1"
                            >
                                合同通过
                            </el-button>
                            <el-button
                                type="text"
                                class="btn-operate"
                                v-if="authResult.auth_admin"
                                @click="fnUnpassContract(scope.row)"
                                :disabled="scope.row.sales_leads && scope.row.sales_leads.contract_verify !== 1"
                            >
                                合同不通过
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
            <!-- /table -->

            <!-- /分页 -->
            <div class="pagination-wrapper clearfix">
                <el-checkbox
                    v-if="authResult.auth_admin"
                    v-model="checkedAll"
                    :indeterminate="checkIndeterminate"
                    @change="fnChangeChecked">全选</el-checkbox>
                <el-button
                    v-if="authResult.auth_admin"
                    size="mini"
                    type="text"
                    :disabled="multipleSelection.length == 0 ? true : false"
                    @click="fnAssignBatch()">委派给销售</el-button>
                <el-pagination
                    background
                    :current-page.sync="page.now_page"
                    :total="page.total_count"
                    :page-size="page.page_size"
                    :layout="deviceType == 'mobile' ? 'prev,next' : 'total,prev,pager,next'"
                    @current-change="getTableData"
                />
            </div>
        </div>
        <!-- 图片预览 -->
        <img-preview ref="preview" />
        <!-- 委派弹窗 -->
        <el-dialog
            title="委派"
            width="470px"
            @close="fnCloseAssignDialog()"
            :visible.sync="dialogAssignShow">
            <el-form
                :model="assignForm"
                :rules="assignFormRules"
                ref="assignForm">
                <el-form-item
                    label="内容"
                    prop="user"
                    label-width="50px">
                    <el-select
                        v-model="assignForm.user"
                        filterable
                        placeholder="请选择">
                        <el-option
                            v-for="item in salers"
                            :key="item.user_no"
                            :label="item.true_name"
                            :value="item.user_no"/>
                    </el-select>
                </el-form-item>
            </el-form>
            <div
                slot="footer"
                class="dialog-footer">
                <el-button @click="fnCloseAssignDialog()">取 消</el-button>
                <el-button
                    type="primary"
                    @click="fnDoAssign()"
                >确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import imgPreview from '@/components/common/img-preview';
import { back } from '@/mixin/back';
import { mapState } from 'vuex';
export default {
    /**
     * @param   {Boolean}    checkIndeterminate         是否选中数据
     * @param   {Array}      multipleSelection          全选的数据
     * @param   {Boolean}    checkedAll                 是否全选
     * @param   {Object}     head                       筛选字段
     * @param   {Object}     filterData                 排序
     * @param   {Object}     page                       分页
     * @param   {Array}      tableData                  数据列表
     * @param   {OBject}     authResult                 权限列表
     */
    mixins: [back],
    components: {
        imgPreview
    },
    data () {
        return {
            checkIndeterminate: false,
            multipleSelection: [],
            checkedAll: false,
            head: {
                name: ''
            },
            filterData: {
                company_name: '',
                verify: '99',
                sales_leads_assign: '99',
                sales_leads_admin_true_name:'',
                sales_leads_contract_verify: '99',
                hire_username: ''
            },
            verify_list:[{
                name:'全部',
                status: '99'
            },{
                name:'待审核',
                status: '1'
            },{
                name:'审核通过',
                status: '2'
            },{
                name:'审核不通过',
                status: '-1'
            }],
            sales_leads_assign_list: [{
                name:'全部',
                status: '99'
            },{
                name:'已指派',
                status: '1'
            },{
                name:'未指派',
                status: '0'
            }],
            sales_leads_contract_verify_list:[{
                name:'全部',
                status: '99'
            },{
                name:'未修改',
                status: '0'
            },{
                name:'待审核',
                status: '1'
            },{
                name:'审核通过',
                status: '2'
            },{
                name:'审核不通过',
                status: '-1'
            }],
            shopType: [{
                name:'普通店',
                status: '1'
            },{
                name:'专营店',
                status: '2'
            },{
                name:'专卖店',
                status: '3'
            },{
                name:'旗舰店',
                status: '4'
            },{
                name:'官方旗舰店',
                status: '5'
            }],
            page: {
                now_page: 1,
                total_count: 0,
                page_size: 0
            },
            tableData: [],
            authResult: {},
            assignHireNos: '',
            assignUser: '',
            salers: [],
            assignForm:{
                user: '',
            },
            assignFormRules:{
                user: [
                    { required: true, message: '请选择委培人员', trigger: 'blur' }
                ]
            },
            dialogAssignShow: false,
            hideSearch: false,
            showHideBtn: false,
        };
    },
    filters: {},
    computed: {
        ...mapState({
            deviceType: state => state.sysinfo.deviceType
        })
    },
    watch: {},
    created(){
        if(this.deviceType == 'mobile'){
            this.hideSearch = true;
            this.showHideBtn = true;
        }
    },
    mounted () {
        this.$store.commit('SET_HEADER', [{ title: "官网"},{title: '官网线索与审核'}]);
        this.authResult = this.$route.meta.authResult;
        this.getTableData(1);
        this.getSalers();
    },
    methods: {
        querySearch(queryString, cb) {
            var restaurants = this.salers;
            var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
            // 调用 callback 返回建议列表的数据

            cb(results);
        },
        createFilter(queryString) {
            return (restaurant) => {
                return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) >= 0);
            };
        },
        /**
         * 获取表格数据
         */
        getTableData (page) {
            this.$post('/student/hire_user_shop_verify%5Cget_list', {
                page_id: page || this.page.now_page,
                ...this.filterData
            }, resp => {
                if (resp.code == 1) {
                    this.tableData = resp.data.list;
                    this.page.now_page = resp.data.page.now_page;
                    this.page.total_count = resp.data.page.total_count;
                    this.page.page_size = resp.data.page.page_size;
                    this.$refs.tableData.doLayout();
                }
            });
        },

        /**
         * 排序
         */
        fnEditSort (row) {
            this.$prompt('请输入排序号', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPattern: /^([1-9]\d?|[1-9]\d+)$/,
                inputErrorMessage: '排序号格式不正确,请重新输入'
            }).then(({ value }) => {
                this.$post('',{
                    //
                },resp=>{
                    if (resp.code == 1) {
                        this.getTableData();
                        this.$notify({
                            title: '成功',
                            message: '操作成功',
                            type: 'success'
                        });
                    } else if (resp.code == 0) {
                        this.$notify({
                            title: '成功',
                            message: '操作成功',
                            type: 'warning'
                        });
                    }
                });
            });
        },

        /**
         * 数据排序
         */
        handleSortChanged(data) {
            let sortTypeMap = {
                ascending: 'asc',
                descending: 'desc'
            };

            let sortFieldMap = {
                //TOD
            };

            if (data.order) {
                this.filterData.sort_field = sortFieldMap[data.prop];
                this.filterData.sort_type = sortTypeMap[data.order];
            } else {
                this.filterData.sort_field = '';
                this.filterData.sort_type = '';
            }

            this.getTableData();
        },

        /**
         * 全选逻辑操作
         */
        fnSelect(selection) {
            if(selection.length == this.tableData.length) {
                this.checkedAll = true;
            }else{
                this.checkedAll = false;
            }
            if(selection.length > 0 && selection.length < this.tableData.length) {
                this.checkIndeterminate = true;
            }else{
                this.checkIndeterminate = false;
            }
        },
        fnSelectAllTop(selection) {
            if(selection.length > 0) {
                this.checkedAll = true;
            }else{
                this.checkedAll = false;
            }
            if(selection.length > 0 && selection.length < this.tableData.length) {
                this.checkIndeterminate = true;
            }else{
                this.checkIndeterminate = false;
            }
        },
        fnChangeChecked() {
            if(this.checkedAll){
                this.toggleSelection(1);
            }else{
                this.toggleSelection();
            }
        },
        toggleSelection(rows) {
            if (rows) {
                this.$refs.tempLateName.toggleAllSelection();
            } else {
                this.$refs.tempLateName.clearSelection();
            }
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },

        /**
         * 查看图片
         * @param   {String}    images      //单图预览
         * @param   {Array}     images      //多图预览
         */
        fnShowPreview(images) {
            if(images && Object.prototype.toString.call(images) == '[object String]') {
                this.$refs.preview.show([
                    images
                ]);
            } else if (images && Object.prototype.toString.call(images) == '[object Array]') {
                this.$refs.preview.show(images);
            } else {
                this.$message({
                    type: 'warning',
                    message: '图片类型错误'
                });
            }
        },

        /**
         * 过滤函数
         */
        emptyFormatter(row, column, val) {
            if (!val) return '--';
            return val;
        },
        shopTypeFormatter(row, column, val) {
            if (!val) return '--';
            for(var i in this.shopType){
                if(this.shopType[i].status == val){
                    return this.shopType[i].name;
                }
            }
            return '--';
        },
        verifyFormatter(row, column, val) {
            if (!val) return '--';
            for(var i in this.verify_list){
                if(this.verify_list[i].status == val){
                    return this.verify_list[i].name;
                }
            }
            return '--';
        },
        assignFormatter(row, column, val) {
            if (!val) return '否';
            return '是';
        },
        statusFormatter(row, column, val) {
            if (!val) return '--';
            for(var i in this.sales_leads_contract_verify_list){
                if(this.sales_leads_contract_verify_list[i].status == val){
                    return this.sales_leads_contract_verify_list[i].name;
                }
            }
            return '--';
        },
        fnResetForm(formName) {
            this.filterData = {
                company_name: '',
                verify: '99',
                sales_leads_assign: '99',
                sales_leads_admin_true_name:'',
                sales_leads_contract_verify: '99'
            };
            this.getTableData(1);
        },
        fnShowVerifyPass(item){
            this.$confirm('请用企业微信与该线索委派的销售进行沟通，询问该销售是否与该客户进行过电销沟通，如已沟通，则可确认通过；一旦通过，则该客户即可以进入企业后台，进行查看后台以及缴纳保证金。是否确认通过？', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.fnVerify(item,2, '');
            }).catch(() => {
            });
        },
        fnShowVerifyUnpass(item){
            this.$prompt('该客户是否有某些字段填写明显错误，请在下方填写你不通过的理由', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                inputPattern: /\S/,
                inputErrorMessage: '请输入审核失败原因'
            }).then(({ value }) => {
                this.fnVerify(item, -1, value);
            }).catch(() => {
            });
        },
        fnVerify(item, status, reason){
            this.$post('/student/hire_user_shop_verify%5Cverify', {
                hire_no: item.hire_no,
                verify: status,
                verify_fail_reason: reason
            }, resp => {
                if(resp.code == 1){
                    this.$notify({
                        title: '成功',
                        message: '操作成功',
                        type: 'success'
                    });
                    item.verify = status;
                }else{
                    this.$notify({
                        title: '警告',
                        message: resp.msg,
                        type: 'warning'
                    });
                }
            });
        },
        fnRemark(item){
            this.$prompt('请输入备注', '', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
            }).then(({ value }) => {
                this.$post('/student/hire_user_shop_verify%5Cremark', {
                    hire_no: item.hire_no,
                    remark:value
                }, resp => {
                    if(resp.code == 1){
                        this.$notify({
                            title: '成功',
                            message: '操作成功',
                            type: 'success'
                        });
                        item.remark = value;
                    }else{
                        this.$notify({
                            title: '警告',
                            message: resp.msg,
                            type: 'warning'
                        });
                    }
                });
            }).catch(() => {
            });

        },
        fnShowContract(url){
            window.open(url);
        },
        selectionFilter(row, index){
            if(!this.authResult.auth_admin){
                return false;
            }
            if(row.sales_leads && !row.sales_leads.admin_no){
                return true;
            }
            return false;
        },
        fnAssignBatch(){
            console.log(this.multipleSelection);
            let assignHireNos = this.multipleSelection.reduce((list, item, index) => {
                // console.log(list, item, index);
                list.push(item.hire_no);
                return list;
            }, []);

            this.assignHireNos = assignHireNos.join(',');
            this.dialogAssignShow = true;
        },
        getSalers(){
            this.$post('/__local/system%5Cuser%5Cget_simple_list', {
                user_group_no: 'gp_eeb08ed101b3e'
            }, resp => {
                if(resp.code == 1){
                    this.salers = resp.data.list;
                }
            });
        },
        fnCloseAssignDialog(){
            this.dialogAssignShow = false;
            this.fnResetForm('assignForm');
        },
        fnAssign(item){
            this.assignHireNos = item.hire_no;
            this.dialogAssignShow = true;
        },
        fnUnassign(item){
            this.$confirm('是否确认移除当前委派？', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$post('/student/hire_user_sales_leads%5Csales_leads_assign', {
                    admin_no: '',
                    hire_nos: item.hire_no
                }, resp => {
                    if(resp.code == 1 ){
                        this.$notify({
                            title: '成功',
                            message: '取消委派成功',
                            type: 'success'
                        });
                        this.dialogAssignShow = false;
                        this.getTableData();
                    } else if (resp.code == 0){
                        this.$notify({
                            title: '警告',
                            message: resp.msg,
                            type: 'warning'
                        });
                    }
                });
            }).catch(() => {
            });
        },
        fnDoAssign(){
            this.$refs.assignForm.validate(valid => {
                if(valid){
                    this.$post('/student/hire_user_sales_leads%5Csales_leads_assign', {
                        admin_no: this.assignForm.user,
                        hire_nos: this.assignHireNos
                    }, resp => {
                        if(resp.code == 1 ){
                            this.$notify({
                                title: '成功',
                                message: '委派成功',
                                type: 'success'
                            });
                            this.dialogAssignShow = false;
                            this.getTableData();
                        } else if (resp.code == 0){
                            this.$notify({
                                title: '警告',
                                message: resp.msg,
                                type: 'warning'
                            });
                        }
                    });
                }
            });
        },
        fnPassContract(item){
            this.$confirm('一旦通过，则企业主后台将立刻可以看到此合同，是否确认通过？', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.fnVerifyContract(item, 2, '');
            }).catch(() => {
            });
        },
        fnUnpassContract(item){
            this.$prompt('请填写合同不通过的理由，并将合同未通过这件事本身告知对应销售以知晓', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                inputPattern: /\S/,
                inputErrorMessage: '请输入审核失败原因'
            }).then(({ value }) => {
                console.log('shenhe', value);
                this.fnVerifyContract(item, -1, value);
            }).catch(() => {
            });
        },
        fnVerifyContract(item, verify, reason){
            console.log('审核中', verify, reason);
            this.$post('/student/hire_user_sales_leads%5Ccontract_verify', {
                hire_no: item.hire_no,
                verify,
                verify_fail_reason: reason
            }, resp => {
                if(resp.code == 1 ){
                    this.$notify({
                        title: '成功',
                        message: '操作成功',
                        type: 'success'
                    });
                    item.sales_leads.contract_verify = verify;
                } else if (resp.code == 0){
                    this.$notify({
                        title: '警告',
                        message: resp.msg,
                        type: 'warning'
                    });
                }
            });
        }
    }
};
</script>

<style lang="less" scoped>
    .container {
        display: flex;
        flex-direction: column;
        width: 100%;
        .header-nav {
            position: relative;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
            .header-left, .header-right {
                display: flex;
                align-items: center;
            }
            .header-new-box {
                display: flex;
                margin-right: 15px;
                align-items: center;
                color: #606266;
                margin-bottom: 10px;
                &-title {
                    margin-right: 2px;
                    white-space: nowrap;
                }
            }
        }
        /* 表单 */
        .scope-price {
            width: 50px;
            height: 50px;
        }
        /* 字体高亮 */
        .cursor-font {
            color: rgb(64, 158, 255);
            cursor: pointer;
        }
        /* 分页 */
        .pagination-wrapper {
            padding-top: 10px;
            padding-bottom: 10px;
            .el-pagination {
                float: right;
                padding: 0;
                background-color: transparent;
            }
        }
    }
    /* 排序 */
    .sort-wrap {
        display: flex;
        align-items: center;
        cursor: pointer;
        .sort-spliter {
            width: 1px;
            height: 12px;
            background: rgba(235, 235, 235, 1);
            margin: 0 10px;
            }
            .btn-sort {
            font-size: 14px;
            line-height: 1;
            color: #ccc;
            &:hover {
                color: #20a0ff;
            }
        }
    }
    .el-button-left {
        margin-left: 40px;
    }
    .el-button-right {
        margin-right: 10px;
    }
    .content-wrapper {
        flex: 1;
        display: flex;
        flex-direction: column;
        margin: 15px;
        overflow: hidden;
    }
    .table-wrapper {
        flex: 1;
        background-color: #fff;
        .normal{
            color: #606266;
        }
        .el-button {
        padding: 0;
        }
        .icon-bianji {
        font-size: 14px;
        color: #b9b9b9;
        cursor: pointer;
        }
        .btn-delete {
        color: #fd4d32;
        &.is-disabled {
            color: #c0c4cc;
            cursor: not-allowed;
        }
        }
        .submit-config-item {
        display: inline-block;
        position: relative;
        padding-right: 10px;
        font-size: 14px;

        & + .submit-config-item {
            padding-left: 10px;
            &::before {
            content: "";
            position: absolute;
            top: 50%;
            left: 0;
            width: 1px;
            height: 14px;
            transform: translate(0, -50%);
            background-color: #d8d8d8;
            }
        }

        .num {
            vertical-align: middle;
        }
        .iconfont {
            font-size: 16px;
            color: #b9b9b9;
            vertical-align: middle;
        }

        .icon-tupian {
            font-size: 20px;
        }
    }
  }
  .search-wrapper {
    padding: 15px;
    background-color: #fff;
  }
  .show-search-btn{
      width: 100%;
      background: #fff;
      text-align: center;
      padding: 5px 0;
      color: #20a0ff;
      background: linear-gradient(to top, #f4f4f4, #fff);
      .iconfont{
          position: relative;
        //   transition: transform 0.3s ease-in-out;
          &.reverse{
              transform: rotate(180deg);
          }
      }
  }
</style>
<style lang="less">
    .sales-leads-wrap{
        .el-table__body-wrapper .el-table__body .el-table__row td {
            border-right: none;
        }
        .el-table__header-wrapper .el-table__header .has-gutter tr th {
            border-right: none;
        }
        .el-table .el-table_1_column_6  .cell {
            position: relative;
        }
        .el-range-editor--small .el-range-separator{
            padding: 0 1px !important;
        }
        .search-wrapper{
            .el-form-item{
                display: inline-block;
            }
        }
        .table-wrapper{
            .el-button {
                padding: 0;
            }
        }
    }
</style>
